package cn.wolfcode.service.impl;

import cn.wolfcode.entity.Region;
import cn.wolfcode.mapper.RegionMapper;
import cn.wolfcode.query.RegionQuery;
import cn.wolfcode.service.IRegionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author c1eye
 * @since 2022-11-03
 */
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService {

    @Override
    public Page<Region> queryPage(RegionQuery regionQuery) {
        Page<Region> pageParam = new Page<>();
        pageParam.setCurrent(regionQuery.getCurrentPage());
        pageParam.setSize(regionQuery.getPageSize());
        QueryWrapper<Region> wrapper = new QueryWrapper<>();
        return page(pageParam, wrapper);
    }

    @Override
    public List<Region> hotRegion() {
        QueryWrapper<Region> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("ishot", 1).orderByAsc("seq");
        return list(queryWrapper);
    }
}
